#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#define MAXSIZE 50
typedef int DataType;
typedef int ElemType;
typedef struct {
	ElemType data[MAXSIZE];
	int front;
	int rear;
}SeqQueue;
void InitQueue(SeqQueue* Q)
{
	Q->front = Q->rear = 0;
}
int EmptyQueue(SeqQueue* Q) //判断是否为队空函数
{
	if (Q->front == Q->rear)
	{
		return 1;
	}
	else
		return 0;
}
int InQueue(SeqQueue* Q, DataType n)//入队
{
	if ((Q->rear + 1) % MAXSIZE == Q->front)
	{
		printf("队满，不能入队元素");
			return 0;
	}
	else
	{
		Q->rear = (Q->rear + 1) % MAXSIZE;
		Q->data[Q->rear] = n;
		return 1;
	}
}
int DeQueue(SeqQueue* Q, DataType* n)//出队
{
	if (EmptyQueue(Q))
	{
		printf("队空，不能出队元素");
	}
	else
	{
		Q->front = (Q->front + 1) % MAXSIZE;
		*n = Q->data[Q->front];
		return 1;
	}
}

void ShowQueue(SeqQueue* Q)//显示队元素
{
	int p = Q->front;
	if (p == Q->rear)
	{
		printf("队列为空，无元素\n");
	}
	else
	{
		printf("从队头起队列中的各元素为：");
		while (p != Q->rear )
		{
			printf("%2d",Q->data[p+1]);
			p++;
		}
	}
}
int main()
{
	int i = 0;
	int flag = 0;
	DataType n;
	DataType x;
    SeqQueue Q;
	int ret = 0;
	for (i = 0; i < 4; i++)
	{
		scanf("%d", &n);
		flag = InQueue(&Q, n);
		if (flag == 0)
		{
			printf("入队操作失败\n");
		}
		else
		{
			printf("入栈操作成功\n");
		}
	}
	scanf("%d", &ret);
	for (i = 0; i < ret; i++)
	{
		flag = DeQueue(&Q, &x);
		printf("%2d", x);

	}
	if (flag == 0)
	{
		printf("出队操作失败\n");
	}
	else
	{
		printf("出栈操作成功\n");
	}
	ShowQueue(&Q);
	return 0;
}